package com.sgai.zero_robot.widget;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.sgai.zero_robot.R;

public class TableItemView extends FrameLayout {

    private TextView tvLeft,tvOne,tvTwo,tvThree,tvFour,tvFive,tvSix,tvSeven,tvEight,tvNine;

    public TableItemView(@NonNull Context context) {
        this(context,null);
    }

    public TableItemView(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,-1);
    }

    public TableItemView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }

    private void initView(Context context) {
        View inflate = View.inflate(context, R.layout.view_table_item, this);
        tvLeft = inflate.findViewById(R.id.tv_left);
        tvOne = inflate.findViewById(R.id.tv_one);
        tvTwo = inflate.findViewById(R.id.tv_two);
        tvThree = inflate.findViewById(R.id.tv_three);
        tvFour= inflate.findViewById(R.id.tv_four);
        tvFive = inflate.findViewById(R.id.tv_five);
        tvSix = inflate.findViewById(R.id.tv_six);
        tvSeven = inflate.findViewById(R.id.tv_seven);
        tvEight = inflate.findViewById(R.id.tv_eight);
        tvNine = inflate.findViewById(R.id.tv_nine);
    }
    public void setDate(String i, String one, String two, String three, String four, String five, String six, String seven, String eight, String nine){
        setText(tvLeft,i);
        setText(tvOne,one);
        setText(tvTwo,two);
        setText(tvThree,three);
        setText(tvFour,four);
        setText(tvFive,five);
        setText(tvSix,six);
        setText(tvSeven,seven);
        setText(tvEight,eight);
        setText(tvNine,nine);
    }
    private void setText(TextView tv,String content){
        if (tv == null){
            return;
        }
        if (!TextUtils.isEmpty(content)){
            tv.setText(content);
        }
    }
}
